package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzbqBusinessusers;
import com.ruoyi.system.service.IDzbqBusinessusersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户信息Controller
 * 
 * @author tianxingxia
 * @date 2025-02-07
 */
@RestController
@RequestMapping("/system/businessusers")
public class DzbqBusinessusersController extends BaseController
{
    @Autowired
    private IDzbqBusinessusersService dzbqBusinessusersService;

    /**
     * 查询客户信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:businessusers:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzbqBusinessusers dzbqBusinessusers)
    {
        startPage();
        List<DzbqBusinessusers> list = dzbqBusinessusersService.selectDzbqBusinessusersList(dzbqBusinessusers);
        return getDataTable(list);
    }

    /**
     * 导出客户信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:businessusers:export')")
    @Log(title = "客户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzbqBusinessusers dzbqBusinessusers)
    {
        List<DzbqBusinessusers> list = dzbqBusinessusersService.selectDzbqBusinessusersList(dzbqBusinessusers);
        ExcelUtil<DzbqBusinessusers> util = new ExcelUtil<DzbqBusinessusers>(DzbqBusinessusers.class);
        util.exportExcel(response, list, "客户信息数据");
    }

    /**
     * 获取客户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:businessusers:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Integer userId)
    {
        return success(dzbqBusinessusersService.selectDzbqBusinessusersByUserId(userId));
    }

    /**
     * 新增客户信息
     */
    @PreAuthorize("@ss.hasPermi('system:businessusers:add')")
    @Log(title = "客户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzbqBusinessusers dzbqBusinessusers)
    {
        return toAjax(dzbqBusinessusersService.insertDzbqBusinessusers(dzbqBusinessusers));
    }

    /**
     * 修改客户信息
     */
    @PreAuthorize("@ss.hasPermi('system:businessusers:edit')")
    @Log(title = "客户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzbqBusinessusers dzbqBusinessusers)
    {
        return toAjax(dzbqBusinessusersService.updateDzbqBusinessusers(dzbqBusinessusers));
    }

    /**
     * 删除客户信息
     */
    @PreAuthorize("@ss.hasPermi('system:businessusers:remove')")
    @Log(title = "客户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Integer[] userIds)
    {
        return toAjax(dzbqBusinessusersService.deleteDzbqBusinessusersByUserIds(userIds));
    }
}
